package com.guli.order.listener;

import com.guli.common.constant.MqConstant;
import com.guli.common.to.SeckillOrderTo;
import com.guli.order.service.OrderService;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.nio.channels.Channel;

/**
 * @Author zzb
 * @Date 2024/4/25 23:41
 * @Version 1.0
 */
@RabbitListener(queues = MqConstant.ORDER_SECKILL_QUEUE)
@Component
public class OrderSeckillListener {
    @Autowired
    private OrderService orderService;

    @RabbitHandler
    public void listener(SeckillOrderTo seckillOrderTo, Channel channel, Message message) {
        orderService.createSeckillOrder(seckillOrderTo);
    }

}
